<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateOpenShopRegionManageUserMapping extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('open_shop_region_manage_user_mapping', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('regionId')->default(0)->comment('大区id');
            $table->unsignedInteger('userId')->default(0)->comment('用户id');
            $table->string('username')->default("")->comment('用户名称');
            $table->unsignedTinyInteger('type')->default(0)->comment('类型 1-负责人 2-附属负责人');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->unsignedTinyInteger('isDeleted')->default(0)->comment('是否删除 0 否 1是');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '大区管理关联负责人';

            $table->index('regionId', 'idx_regionId');
            $table->index('userId', 'idx_userId');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('open_shop_region_manage_user_mapping');
    }
}
